package sft.Autenticacao;

import sft.BancodeDados.CriaConexao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class Observacao {

    private static Observacao instance = null;
    private static Connection conexao;
    private String acao;
    private String user;
    private String data;
    
    public Observacao() {
    }    

    public String getAcao() {
        return acao;
    }

    public void setAcao(String acao) {
        this.acao = acao;
    }

    public String getUser() {
        return user;
    }

    public void setUser(String user) {
        this.user = user;
    }

    public String getData() {
        return data;
    }

    public void setData(String data) {
        this.data = data;
    }
    
    public static Observacao getInstance() {
        if(instance == null){
            instance = new Observacao();
        }
        return instance;
    }
    
    public void gravaOBS() throws SQLException{
        conexao = new CriaConexao().getConnection();
        
        String sql = "insert into sft_log (log_nm_nmlog, log_ac_aclog, log_dt_dtlog) values (?,?,?)";
        
        PreparedStatement stmt = conexao.prepareStatement(sql);
        stmt.setString(1, Sessao.getInstance().getUsuario().getNome());
        stmt.setString(2, Observacao.getInstance().getAcao());
        stmt.setString(3, Observacao.getInstance().getData());
        
        stmt.execute();
        stmt.close();
        conexao.close();
    }
}
